﻿using System;
using System.Xml.Serialization;
using DC2010.Objects.Base;
using DC2010.Objects.Data;

namespace DC2010.Objects.Structures
{
    public class ActionInfo : BaseInfo
    {
        [XmlAttribute]
        public string Name { get; set; }

        /// <summary>
        /// probably same as id. This is used to determine which action to lanuch
        /// </summary>
        [XmlAttribute]
        public string Method { get; set; }

        /// <summary>
        /// Skill to be improved
        /// </summary>
        [XmlAttribute]
        public SkillNames ImprovedSkill { get; set; }

        /// <summary>
        /// How much experience u will gain
        /// </summary>
        [XmlAttribute]
        public int ExperienceGain { get; set; }

        /// <summary>
        /// Defense modifier applied until the champion can make an action again.
        /// </summary>
        [XmlAttribute]
        public int DefenseModifier { get; set; }

        /// <summary>
        /// The base value of stamina used when making the action.
        /// </summary>
        [XmlAttribute]
        public int Stamina { get; set; }

        /// <summary>
        /// The probability to hit (0..75, 75 means automatic hit).
        /// </summary>
        [XmlAttribute]
        public int HitProbability { get; set; }

        /// <summary>
        /// Damage modifier (in 1/32's). A value of 16 then would be "half normal damage".
        /// </summary>
        [XmlAttribute]
        public int Damage { get; set; }

        /// <summary>
        ///  The amount of time before you can make another action (1/6ths of a second).
        /// </summary>
        [XmlAttribute]
        public int Fatique { get; set; }
		
        /// <summary>
        /// Number of required skill. Otherwise option will not be displayed
        /// </summary>
		[XmlAttribute]
		public int RequiredSkill {get;set;}
		
        /// <summary>
        /// How much experience do you need. Otherwise option will not be displayed
        /// </summary>
		[XmlAttribute]
		public int RequiredSkillExp {get;set;}

        /// <summary>
        /// How many charges. For example staff with ability to throw fireballs...if current charges=0 than this action cannot be executed.
        /// </summary>		
        public CurrentNormal Charges { get; set; }

        public ActionData CreateData()
        {
            ActionData cd = new ActionData();

            cd.InfoId = Id;
            cd.Id = cd.InfoId + "_" + Guid.NewGuid();

			cd.ImprovedSkill = ImprovedSkill;
			cd.ExperienceGain  = ExperienceGain;
			cd.DefenseModifier = DefenseModifier;
			cd.Stamina = Stamina;
			cd.Damage = Damage;
			cd.Fatique = Fatique;
			
            Root.log.InfoFormat("Core, Created new ACTION with id: {0} based on object {1}", cd.Id, cd.InfoId);
            Root.I.ActionSystem.AddData(cd);
            return cd;
        }


    }
}
